//
// Created by fengg on 2020/3/11.
//

#include <iostream>

#define STR_LENGTH   5000
#define STACK_LENGTH 100
template <class T>
class ExpStack{
private:
    T *stack;
    int last;
    int sizeI;
public:
    explicit ExpStack(int size){
        stack = new T[size];
        sizeI = size;
        last = 0;
    }

    void push(T value){
        if(last >= sizeI)
            return;
        this->stack[this->last++] = value;
    }

    T pop(){
        if(this->last <= 0)
            return this->stack[0];
        else
            return this->stack[--this->last];
    }

    T tail(){
        return this->stack[this->last-1];
    }
    bool isEmpty(){
        return this->last <= 0;
    }
};

using namespace std;

int main(){
    ExpStack<long long> *intStack = new ExpStack<long long>(STACK_LENGTH);
    ExpStack<char> *opStack = new ExpStack<char>(STACK_LENGTH);

    long long  temp = 0;
    char cstr[STR_LENGTH] = {0x0};

    cin >> cstr;
    long long i = 0;
    while (cstr[i] != 0x0 && i < STR_LENGTH){
        if(isdigit(cstr[i])){
            temp = temp*10+(cstr[i]-'0');
        }

        else {
            intStack->push(temp);
            temp = 0;

            switch (cstr[i]) {
                case '+':
                    while(opStack->tail() == '*'){
                        opStack->pop();
                        long long a = intStack->pop();
                        long long b = intStack->pop();
                        intStack->push((a*b)%10000);
                    }
                    break;
                case '*':

                    break;
            }
            opStack->push(cstr[i]);
        }
        i++;
    }
    intStack->push(temp);
    while (!opStack->isEmpty()){


        switch( opStack->pop()){
            case '+':
                if(!intStack->isEmpty())
                    intStack->push( (intStack->pop() + intStack->pop())%10000);
                break;
            case '*':
                if(!intStack->isEmpty())
                    intStack->push( (intStack->pop() * intStack->pop())%10000);
                break;
        }

    }
    cout << intStack->pop()%10000;
    return 0;
}